<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> 

    <!--{include file='comm/header.tpl'}-->  
    <title>基础设置</title>
    <!--{include file='comm/comm_cal.tpl'}-->
    <!--{include file='comm/comm_editor.tpl'}-->
    <!--引用div做成的下拉框效果样式-->
    <link rel="stylesheet" href="/quanliadmin/docroot/css/department_select.css" type="text/css" media="screen" />

    <!--引用div做成的下拉框效果js-->
    <script language="JavaScript" src="/quanliadmin/docroot/js/department_select.js" type="text/javascript"></script>
</head>

<body>

<style>
    .imageSites{
        position: absolute;
        left:275px;
        top:8px;
    }
    .search_option_drop{
        width:300px;
    }

</style>

<div class="container">
   
    
        <div class="comm_content">
            <div class="search-box">
                <div style="position:relative">
                    <form class="form-inline" id="search_form" onsubmit="return false;">
                            <span>
                               分类名称：<input type="text"  class="form-control input-sm" name="categoryName" id="categoryName" style="width:150px;"/>
                            </span>
                            <span>
                                <button type="button" class="btn btn-primary" id="searchBtn" onclick="basicSetting.search();">查询</button>
                            </span>
                            <span>
                                <button type="button" class="btn btn-warning" id="clearBtn" onclick="basicSetting.clearUp();" >重置</button>
                            </span>
                    </form>
                </div>
            </div>
             <div id="pop" style="display: none;">
                <form id="categoryForm" class="form-horizontal" role="form" onsubmit="return false;">
                     <input type="hidden" id="itemCategoryID" name="itemCategoryID" value=""/>
                  <div class="form-group">
                      <label for="itemCategoryName" class="col-sm-3 control-label">分类名称：</label>
                      <div class="col-sm-9">
                     <input type="text" class="form-control" id="itemCategoryName" name="itemCategoryName" placeholder="请输入分类名称" style="width: 350px"/>
                    </div>
                  </div>
                </form>
            </div>
            <table id="flex" style="display:none"></table>
        </div>
  
</div>
<script type="text/javascript">
 
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/system/basicSetting.ajax?operFlg=1",
        dataType: "json",
        colModel : [

            {display: "操作", width : 100, align: "center"},
            {display: "分类编号", width : 100, align: "center"},
            {display: "分类名称", width : 140,align:"left"}
        ],
        buttons : [
            {name: "添加", bclass: "add", onpress : "basicSetting.add"}
        ],
        sortname: "createTime",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    var basicSetting = {

        itemCategoryID:'',
        itemID:'',
        selected:'',
        //搜索
        search: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },
          //添加分类信息
        add: function() {
            E.popup.open({
                id:"pop",                  //获取id为"pop"元素内的HTML
                title:"添加分类",       //弹出层标题
                css: "width:550px;",   //设置弹出层样式
                btnName: "保存",        //执行“确定”操作的按钮名称
                btnCall:"basicSetting.checkInfo();"  //点击确定后执行的方法
            });        
        },
          //验证分类信息
        checkInfo:function(){
            var data = E.getFormValues("categoryForm");
            var error_msg = "";
            //代金卡id
            var itemCategoryID = data.itemCategoryID;
            //验证分类名称
            if (data.itemCategoryName == ''){
                error_msg += '分类名称不能为空<br/>';
            }
            if (error_msg != ""){
                E.alert(error_msg);
            }else{
                E.confirm('您确认添加[ ' + data.itemCategoryName + ' ]分类吗?', "basicSetting.addExe");
            }
        },
          //执行 添加
        addExe: function() {
            //弹出遮罩层
            E.loadding.open("执行中……");
            //获取表单参数
            var data = E.getFormValues('categoryForm');
            jquery_ajax(100,data,basicSetting.callback);
            //关闭弹出层
            E.popup.close();
            //关闭遮罩层
            E.loadding.close();
        },
        /**
         * 编辑分类
         */
    edit: function( itemCategoryID ) {
        E.loadding.open("正在查询，请稍后...");
        E.ajax_post({
            url:"/invokingAjax-backend/system/basicSetting.ajax?operFlg=2&act",
            data:{itemCategoryID:itemCategoryID},
            call:"basicSetting.editResult"
        });
    //显示弹出层
        E.popup.open({
            id:"pop",
            title: "修改分类",
            css: "width:550px;",
            btnName: "确认修改",
            btnCall:"basicSetting.editCheck();"
        });
    },
    //查询结果
    editResult:function(o){
        E.loadding.close();
        if( o.code != 200 ){
            E.alert( o.message );
            return false;
        }
        var data = o.data;
        $('#itemCategoryName').val(data.itemCategoryName);
        $('#itemCategoryID').val(data.itemCategoryID);
    },
    //修改验证
    editCheck:function(){
        var data = E.getFormValues("categoryForm");
        var error_msg = '';
       //验证分类名称
        if (data.itemCategoryName == ''){
               error_msg += '分类名称不能为空<br/>';
        }
        if (error_msg != ""){
                E.alert(error_msg);
        }else{
                E.confirm('您确认修改[ ' + data.itemCategoryName + ' ]分类吗?', "basicSetting.editExe");
        }

    },
    //编辑执行
    editExe:function(){
       //弹出遮罩层
        E.loadding.open("正在执行，请稍后...");
        //获取表单参数
        var data = E.getFormValues('categoryForm');
        jquery_ajax(100,data,basicSetting.callback);
        //关闭弹出层
        E.popup.close();
        //关闭遮罩层
        E.loadding.close();
    },
    
//选项操作
  option: {
            
    search: function( itemCategoryID ) {
        this.itemCategoryID = itemCategoryID;
        basicSetting.itemCategoryID = itemCategoryID;

        E.loadding.open('正在查询，请稍候...');

        //========================================================================================================
        //生日牌图片维护 编号33 注释
        if( this.itemCategoryID == 33){
            E.ajax_post({
                url:  "/invokingAjax-backend/system/basicSetting.ajax?operFlg=3",
                data: {
                    itemCategoryID: itemCategoryID
                },
                call: "basicSetting.option.openUpload"
            });
        //========================================================================================================
        }else if( this.itemCategoryID == 1){ //促销渠道
            E.ajax_post({
                url:  "/invokingAjax-backend/system/basicSetting.ajax?operFlg=3",
                data: {
                    itemCategoryID: itemCategoryID
                },
                call: "basicSetting.option.openPromotion"
            });
        }else{
            E.ajax_post({
                url:  "/invokingAjax-backend/system/basicSetting.ajax?operFlg=3",
                data: {
                    itemCategoryID: itemCategoryID
                },
                call: "basicSetting.option.open"
            });
        }


    },

    //生日牌图片上传
    openUpload:function( o ){
        E.loadding.close();

        var html = '';

        html += '<div class="panel panel-default">';
        html += '<div class="panel-heading">保存分类选项</div>';
        html += '<div class="panel-body">';
        html +='<form id="itemForm" class="form-horizontal" role="form" onsubmit="return false;">';
        html +='<input type="hidden" id="itemID" name="itemID" value=""/>';
        html +='<input type="hidden" id="itemCategoryID" name="itemCategoryID" value="'+this.itemCategoryID+'"/>';
        html +='<div class="form-group">';
        html +='<label for="itemName" class="col-sm-2 control-label">分类选项:</label>';
        html +='<div class="col-sm-5">';

        html +='<button type="button" class="btn btn-default" id="update_logo">点击上传生日牌图片</button>';
        html +='<div id="logo_img_box" style="display: none;margin-top: 5px;"></div>';
        html +='<input type="hidden" id="itemName" name="itemName" value="" />';


        //html +='<input type="text" class="form-control" id="itemName" name="itemName" value=""  placeholder="请输入分类选项名称" style="width: 200px"/>';
        html +='</div>';
        html +='<button type="button" class="btn btn-success" id="saveBtn" onclick="basicSetting.option.edit.check();">保存</button>&nbsp;&nbsp;';
        html +='<button type="button" class="btn btn-warning" id="clearBtn" onclick="basicSetting.option.edit.clear();">取消</button>';
        html +='</div>';
        html +='</form>';
        html +='</div>';
        html +='</div>';


        html += '<div class="panel panel-default">';
        html += '<div class="panel-heading">分类选项列表</div>';

        html += '<table class="table">';
        html += '<thead>';
        html += '<tr>';
        html += '<th style="text-align:center;width:150px" >操作</th>';
        html += '<th style="width:500px">选项名</th>';
        html += '<th style="text-align:center;width:150px" >状态</th>';
        html += '</tr>';
        html += '</thead>';

        html += '<tbody id="item_box">';
        if (o.data) {
            $.each(o.data, function(k, v) {
                var status ="";
                if(v.useFlg ==1){
                    status +='启用';
                }else {
                    status +='禁用';
                }
                html += '<tr>';
                html += '<td style="text-align:center"><a href="javascript:void(0)" onclick="basicSetting.option.edit.selectItem('+v.itemID+')">修改</a>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" class="remove" onclick="basicSetting.option.edit.delItem('+v.itemID+',this)">删除</a></td>';
                html += '<td id="item_name_' + v.itemID + '">' + v.itemName + '</td>';
                html += '<td style="text-align:center"><a href="javascript:void(0)" onclick="basicSetting.option.edit.statusChange('+v.useFlg+' ,'+v.itemID+',this)">' +status+'</a></td>';
                html += '</tr>';
            });
        }
        html += '</tbody>';

        html += '</table>'
        html += '</div>';

        E.popup.open({
            content: html,
            title: '分类选项',
            css: 'width: 800px;'
        });

    },

      //add by 2014-12-03 xuhongshun  start
      openPromotion: function( o ) {

          E.loadding.close();

          var html = '';

          html += '<div class="panel panel-default">';
          html += '<div class="panel-heading">保存分类选项</div>';
          html += '<div class="panel-body">';
          html +='<form id="itemForm" class="form-horizontal" role="form" onsubmit="return false;">';
          html +='<input type="hidden" id="itemID" name="itemID" value=""/>';
          html +='<input type="hidden" id="itemCategoryID" name="itemCategoryID" value="'+this.itemCategoryID+'"/>';
          html +='<div class="form-group">';
          html +='<label for="itemName" class="col-sm-3 control-label">分类选项:</label>';
          html +='<div class="col-sm-5">';
          html +='<input type="text" class="form-control" id="itemName" name="itemName" value=""  placeholder="请输入分类选项名称" style="width: 200px"/>';
          html +='</div>';
          html +='</div>';

          html +='<div class="form-group">';
          html +='<label for="itemName" class="col-sm-3 control-label">部门:</label>';
          html +='<div class="col-sm-5">';
          html +='<div class="search_option">';
          html +='<div class="search_option_drop" >';
          html +='<div id="searchOptions" style="width: 300px;height:28px;">';
          html +='请选择';
          html +='<font class="imageSites" ><img src="/quanliadmin/docroot/images/comm/selects.jpg"></font>';
          html +='</div>';
          html +='</div>';
          html +='<ul class="search_option_panel"  id="searchPanels" style="display: none;z-index: 100;">';
          html +='<li class="childSelectImg" departmentID="" style="margin-top:5px;margin-bottom:5px;margin-left: 0px;font-size: 13px;" >请选择</li>';
          html +='<!--{$department_select_html}-->';
          html +='</ul>';
          html +='<input type="hidden" value="0" id="hdnSearchTypes" name="hdnSearchType">';
          html +='<input type="hidden" value="" id="search_departmentID" name="search_departmentID">';
          html +='<input type="hidden" value="" id="departmentName" name="departmentName">';
          html +='</div>';
          html +='</span>';


          html +='</div>';
          html +='</div>';
          html +='<div class="form-group">';
          html +='<div align="center">';
          html +='<button align="center" type="button" class="btn btn-success" id="saveBtn" onclick="basicSetting.option.edit.check();">保存</button>&nbsp;&nbsp;';
          html +='<button type="button" class="btn btn-warning" id="clearBtn" onclick="basicSetting.option.edit.clear();">取消</button>';
          html +='</div>';
          html +='</div>';
          html +='</div>';
          html +='</form>';
          html +='</div>';



          html += '<div class="panel panel-default">';
          html += '<div class="panel-heading">分类选项列表</div>';

          html += '<table class="table">';
          html += '<thead>';
          html += '<tr>';
          html += '<th style="text-align:center;width:100px" >操作</th>';
          html += '<th style="width:250px">选项名</th>';
          html += '<th style="width:150px" >部门</th>';
          html += '<th style="text-align:center;width:100px" >状态</th>';
          html += '</tr>';
          html += '</thead>';

          html += '<tbody id="item_box">';

          //mod by 2014-12-04 xuhongshun 促销渠道调整 start
          if (o.data) {

              $.each(o.data, function(k, v) {
                  var status ="";
                  if(v.useFlg ==1){
                      status +='启用';
                  }else {
                      status +='禁用';
                  }
                  if( v.extend_1 ){
                      var extend_1 = v.extend_1;
                      var extend_2 = v.extend_2;
                  }else{
                      var extend_1 = "";
                      var extend_2 = "";
                  }
                  html += '<tr>';
                  html += '<td style="text-align:center"><a href="javascript:void(0)" onclick="basicSetting.option.edit.selectItem('+v.itemID+')">修改</a>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" class="remove" onclick="basicSetting.option.edit.delItem('+v.itemID+',this)">删除</a></td>';
                  html += '<td id="item_name_' + v.itemID + '">' + v.itemName + '</td>';
                  html += '<td id="item_name_' + v.itemID + '_' +'">' + extend_2 + '</td>';
                  html += '<td style="text-align:center"><a href="javascript:void(0)" onclick="basicSetting.option.edit.statusChange('+v.useFlg+' ,'+v.itemID+',this)">' +status+'</a></td>';
                  html += '</tr>';
              });
          }
          //mod by 2014-12-04 xuhongshun 促销渠道调整 end
          html += '</tbody>';

          html += '</table>'
          html += '</div>';

          E.popup.open({
              content: html,
              title: '分类选项',
              css: 'width: 600px;'
          });

      },
      //add by 2014-12-03 xuhongshun  end

    open: function( o ) {

         E.loadding.close();

         var html = '';

         html += '<div class="panel panel-default">';
         html += '<div class="panel-heading">保存分类选项</div>';
         html += '<div class="panel-body">';
         html +='<form id="itemForm" class="form-horizontal" role="form" onsubmit="return false;">';
         html +='<input type="hidden" id="itemID" name="itemID" value=""/>';
         html +='<input type="hidden" id="itemCategoryID" name="itemCategoryID" value="'+this.itemCategoryID+'"/>';
         html +='<div class="form-group">';
         html +='<label for="itemName" class="col-sm-2 control-label">分类选项:</label>';
         html +='<div class="col-sm-5">';
         html +='<input type="text" class="form-control" id="itemName" name="itemName" value=""  placeholder="请输入分类选项名称" style="width: 200px"/>';
         html +='</div>';
         html +='<button type="button" class="btn btn-success" id="saveBtn" onclick="basicSetting.option.edit.check();">保存</button>&nbsp;&nbsp;';
         html +='<button type="button" class="btn btn-warning" id="clearBtn" onclick="basicSetting.option.edit.clear();">取消</button>';
         html +='</div>';
         html +='</form>';
         html +='</div>';
         html +='</div>';


         html += '<div class="panel panel-default">';
         html += '<div class="panel-heading">分类选项列表</div>';

         html += '<table class="table">';
         html += '<thead>';
         html += '<tr>';
         html += '<th style="text-align:center;width:150px" >操作</th>';
         html += '<th style="width:300px">选项名</th>';
         html += '<th style="text-align:center;width:150px" >状态</th>';
         html += '</tr>';
         html += '</thead>';

         html += '<tbody id="item_box">';
         if (o.data) {
             $.each(o.data, function(k, v) {
                    var status ="";
                    if(v.useFlg ==1){
                        status +='启用';
                     }else {
                        status +='禁用';
                    }
                    html += '<tr>';
                    html += '<td style="text-align:center"><a href="javascript:void(0)" onclick="basicSetting.option.edit.selectItem('+v.itemID+')">修改</a>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" class="remove" onclick="basicSetting.option.edit.delItem('+v.itemID+',this)">删除</a></td>';
                    html += '<td id="item_name_' + v.itemID + '">' + v.itemName + '</td>';
                    html += '<td style="text-align:center"><a href="javascript:void(0)" onclick="basicSetting.option.edit.statusChange('+v.useFlg+' ,'+v.itemID+',this)">' +status+'</a></td>';
                    html += '</tr>';
             });
        }
         html += '</tbody>';

         html += '</table>'
         html += '</div>';

         E.popup.open({
            content: html,
            title: '分类选项',
            css: 'width: 600px;'
        });

    },
            
   //编辑包括（删除，修改，添加，启用禁用）
    edit: {

       dt: '',

       check: function() {
            this.dt = E.getFormValues("itemForm");
            var error_msg = "";
            if ( this.dt.itemName == '' ) {
                   error_msg += "分类选项名称不能为空<br />";
            }

            if (error_msg != "") {
                   E.alert(error_msg);
             } else {
                   E.confirm('您确认保存该分类选项吗?', "basicSetting.option.edit.execute");
             }
        },

        execute: function() {
            E.loadding.open('正在保存，请稍候...');
            E.ajax_post({
                url:"/invokingAjax-backend/system/basicSetting.ajax?operFlg=101", //传递到后台
                data: this.dt,
                call:"basicSetting.option.edit.result"
            });
        },

        result: function( obj ) {
            E.loadding.close();
            if ( obj.code != 200 ) {
                E.alert( obj.message );
                return false;
            } else {
                //mod by 2014-12-04 促销渠道加部门信息 xuhongshun  start
                if( obj.data.itemCategoryID == 1){
                    if( obj.data.extend_2 ){
                        var extend_2 = obj.data.extend_2;
                    }else{
                        var extend_2 = "";
                    }
                }

                E.alert( obj.message, 2 );
                $("#itemName").val('');
                $("#itemID").val('');

                if (this.dt.itemID) {
                    $('#item_name_' + this.dt.itemID).text(obj.data.itemName);
                    if( obj.data.itemCategoryID == 1){
                        //alert( this.dt.itemID + '_' + obj.data.extend_1 );
                        $('#item_name_' + this.dt.itemID + '_' ).text(obj.data.extend_2);
                    }
                } else {
                    var html = '<tr>';
                    html += '<td style="text-align:center"><a href="javascript:void(0)" onclick="basicSetting.option.edit.selectItem('+obj.data.itemID+')">修改</a>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" class="remove" onclick="basicSetting.option.edit.delItem('+obj.data.itemID+',this)">删除</a></td>';
                    html += '<td>' + obj.data.itemName + '</td>';
                    if( obj.data.itemCategoryID == 1){
                        html += '<td>' + obj.data.extend_2 + '</td>';
                    }
                    html += '<td style="text-align:center"><a href="javascript:void(0)" onclick="basicSetting.option.edit.statusChange(1 ,'+obj.data.itemID+',this)">启用</a></td>';
                    html += '</tr>';
                    $("#item_box").append(html);
                }
            }

            //mod by 2014-12-04 促销渠道加部门信息 xuhongshun end
        },

        selectItem: function( itemID ) {
            E.loadding.open("正在查询，请稍后...");
            E.ajax_post({
                url:"/invokingAjax-backend/system/basicSetting.ajax?operFlg=6",
                data: {
                    itemID: itemID
                },
                call:"basicSetting.option.edit.selectItemResult"
            });
        },

        selectItemResult: function( o ) {
            E.loadding.close();
            if( o.code != 200 ){
                E.alert( o.message );
                return false;
            }
            var data = o.data;
            $('#itemForm #itemName').val(o.data.itemName);
            $('#itemForm #itemID').val(o.data.itemID);

            if( o.data.itemCategoryID == 1){
                if( o.data.extend_1 ){
                    var spanValues = o.data.extend_2 + '<font class="imageSites"><img src="/quanliadmin/docroot/images/comm/selects.jpg"></font>';
                }else{
                    var spanValues =  '请选择' + '<font class="imageSites"><img src="/quanliadmin/docroot/images/comm/selects.jpg"></font>';
                }
                $("#searchOptions").html(spanValues);
            }else if( o.data.itemCategoryID == 33 ){
                var html = '<img style="width:110px;height: 110px;" src="' + o.data.itemName + '"> <a href="javascript: void(0);" id="del_log_img">删除</a>';
                $('#logo_img_box').html(html);
                $('#logo_img_box').show();
            }

        },

        //删除选项分类
        delItem:function( itemID,thisObj ){
            this.selected = $( thisObj ).parents("tr");
            this.itemID = itemID;
           E.confirm('您确认删除该分类选项吗?','basicSetting.option.edit.delExe');
         },

        delExe:function(){
            //add by xuhongshun 2014-12-25 生日牌图片维护 start
            if(  basicSetting.itemCategoryID == 33 ){
                $('#logo_img_box').html('');
                $('#logo_img_box').hide();
            }
            //add by xuhongshun 2014-12-25 生日牌图片维护 end
            $.ajax({
                 type: "POST",
                 url: "/invokingAjax-backend/system/basicSetting.ajax?operFlg=4",
                 dataType: "JSON",
                 data:{
                     itemID: this.itemID
                 },
                 success: function(result_obj){
                     if (result_obj.code == 200) {
                         E.alert(result_obj.message, 2);
                         basicSetting.option.edit.selected.remove();
                     }
                     else {
                         E.alert(result_obj.message);
                     }
                 }
             });
        },

        //启用/禁用分类选项
        statusChange:function( useFlg,itemID,thisObj ){
            this.selected = $( thisObj );
            this.itemID = itemID;
            this.useFlg = useFlg;
            if( useFlg == 1 ){
                E.confirm("您确认<b>禁用</b>该分类选项吗？", "basicSetting.option.edit.changeExe");
            }else{
                E.confirm("您确认<b>启用</b>该分类选项吗？", "basicSetting.option.edit.changeExe");
            }
        },

        //执行启用禁用操作
        changeExe:function(){
            E.loadding.open("正在执行，请稍后...");
            jquery_ajax(5, {itemID: this.itemID ,useFlg:this.useFlg} , basicSetting.option.edit.msg );
        },
        //对ajax返回的信息进行提示
        msg: function( obj ) {
            if( obj.code == 200 ){
                E.loadding.close();
                E.alert( obj.message,2);
                if(basicSetting.option.edit.useFlg == 1){
                    basicSetting.option.edit.selected.attr("onclick",'basicSetting.option.edit.statusChange( 2,'+basicSetting.option.edit.itemID+',this)')
                    basicSetting.option.edit.selected.html("禁用");
                }else{
                    basicSetting.option.edit.selected.attr("onclick",'basicSetting.option.edit.statusChange( 1,'+basicSetting.option.edit.itemID+',this)')
                    basicSetting.option.edit.selected.html("启用");
                }
            }else{
                E.loadding.close();
                E.alert(obj.message,1);
            }
        },
        //重置分类选项名称
        clear:function(){
            var searchOptions= "请选择" +'<font class="imageSites"><img src="/quanliadmin/docroot/images/comm/selects.jpg"></font>';
            $('#searchOptions').html( searchOptions );
            $("#search_departmentID").val('');
            $("#departmentName").val('');
            $("#itemID").val('');
            $("#itemName").val('');

        }
     }
   },

    //回调函数
    callback: function( obj ) {
        E.loadding.close();
        E.popup.close();
        if( obj.code == 200 ){
            E.alert( obj.message , 2 , 'basicSetting.load');
        }else{
            E.alert(obj.message);
        }
    },
    load: function() {
        $("#flex").flexReload();
    },
    //重置分类名称
    clearUp:function() {
        $("#categoryName").val('');
        basicSetting.load();
    }
};
    function jquery_ajax(flg,data,func){
        $.ajax({
            type: "post",
            url: "/invokingAjax-backend/system/basicSetting.ajax?operFlg="+flg,
            dataType: "json",
            data: data,
            success: function( result_obj ) {
                func(result_obj);
            },
            error : function(msg){
                alert('网络不给力，请重新尝试...');
            }
        });
    }


    //绑定上传图片
    KindEditor.ready(function(K) {

        var kindEditor_upload = K.editor({
            allowFileManager : true,
            uploadJson: '/framework/kindeditor/php/upload_json.php?act=system'
        });

        $(document).on('click', '#update_logo', function() {

            kindEditor_upload.loadPlugin('image', function() {
                kindEditor_upload.plugin.imageDialog({
                    showRemote : false,
                    clickFn : function(url) {

                        $('#logo_img_box').html('<img style="width:110px;height: 110px;" src="' + url + '"> <a href="javascript: void(0);" id="del_log_img">删除</a>').show();
                        $('#itemName').val(url);
                        kindEditor_upload.hideDialog();

                    }
                });
            });

        });

        $(document).on('click', '#del_log_img', function() {
            $('#logo_img_box').html('').hide();
            $('#itemName').val('');
        });

    });

    //add by 2014-12-03 促销渠道加部门信息 js控制 xuhongshun  start
    $(document).on("click","#searchPanels li",function(){
        var spanValues = $(this).text() + '<font class="imageSites"><img src="/quanliadmin/docroot/images/comm/selects.jpg"></font>';
        $("#searchOptions").html(spanValues);
        var departmentID = $(this).attr('departmentID');
        if( departmentID == 0 ){
            $("#search_departmentID").val(departmentID);
            //$("#departmentName").val('');//当前选中部门赋值给input
        }else{
            $("#search_departmentID").val(departmentID);
            $("#departmentName").val($(this).text());//当前选中部门赋值给input
        }

        $("#searchPanels").hide();
        // 保存当前所选类型(0:Product；1:Seller)
        $("#hdnSearchTypes").val($("#searchPanel li").index($(this)));
    });
    //add by 2014-12-03 促销渠道加部门信息js控制 xuhongshun  start
</script>
</body>
</html>